//# sourceURL=http://uMapApp/Earth/EarthSetting
define([
    "mhjs/mhjs",
    "uMap/uMap",
    "uEarth/uEarth",
    "./ViewPort"
], function (
    mhjs,
    uMap,
    uEarth,
    ViewPort
) {

    function EarthSetting(earth, option) {

        var _this = this;

        if (earth) {
            _this.earth = earth;
            option && _this.OptionToProperties(option);
        }

    }

    var _class = EarthSetting;

    Object.defineProperties(_class.prototype, {
        isImageryShow       : {
            get: function () {
                return this._isImageryShow;
            },
            set: function (boolean) {

                var _this = this;

                $.each(_this.earth.imageryLayers._layers, function (i, imageLayer) {
                    if (!imageLayer.isBaseLayer()) {
                        imageLayer.show = boolean;
                    }
                });

                _this._isImageryShow = boolean;

                _this.trigger("change");

            }
        },
        isTerrainShow       : {
            get: function () {
                return this._isTerrainShow;
            },
            set: function (boolean) {

                var _this = this;

                if (boolean) {
                    _this.earth.terrainProvider = _this.oldTerrain || _this.earth.terrainProvider;
                } else {
                    _this.oldTerrain = _this.earth.terrainProvider;
                    _this.earth.terrainProvider = new uEarth.EllipsoidTerrainProvider();
                }

                _this._isTerrainShow = boolean;

                _this.trigger("change");

            }
        },
        isShowWaterSurface  : {
            get: function () {
                return this._isShowWaterSurface;
            },
            set: function (boolean) {
                var _this = this;
                //todo 水面设置
                _this._isShowWaterSurface = boolean;

                _this.trigger("change");
            }
        },
        isShowSun           : {
            get: function () {
                return this._isShowSun;
            },
            set: function (boolean) {
                var _this = this;
                _this.earth.scene.sun.show = boolean;
                _this._isShowSun = boolean;

                _this.trigger("change");
            }
        },
        isShowSky           : {
            get: function () {
                return this._isShowSky;
            },
            set: function (boolean) {
                var _this = this;
                _this.earth.scene.skyBox.show = boolean;
                _this._isShowSky = boolean;

                _this.trigger("change");
            }
        },
        isShowAtmosphere    : {
            get: function () {
                return this._isShowAtmosphere;
            },
            set: function (boolean) {
                var _this = this;
                _this.earth.scene.skyAtmosphere.show = boolean;
                _this._isShowAtmosphere = boolean;

                _this.trigger("change");
            }
        },
        isShowGridImagery   : {
            get: function () {
                return this._isShowGridImagery;
            },
            set: function (boolean) {
                var _this = this;

                if (boolean) {
                    _this.gridImagery = _this.earth.scene.imageryLayers.addImageryProvider(new uEarth.GridImageryProvider({
                        cells          : 0,
                        backgroundColor: uEarth.Color.TRANSPARENT
                    }));
                    _this.earth.scene.imageryLayers.raiseToTop(_this.gridImagery);

                } else {
                    _this.gridImagery && _this.earth.scene.imageryLayers.remove(_this.gridImagery);
                }


                _this._isShowGridImagery = boolean;

                _this.trigger("change");
            }
        },
        isShowCompass       : {
            get: function () {
                return this._isShowCompass;
            },
            set: function (boolean) {
                var _this = this;
                if (_this.earth.cesiumWidget.cesiumNavigation) {
                    $(_this.earth.cesiumWidget.cesiumNavigation.navigationDiv).toggle(boolean);
                }
                _this._isShowCompass = boolean;

                _this.trigger("change");
            }
        },
        isShowDistanceLegend: {
            get: function () {
                return this._isShowDistanceLegend;
            },
            set: function (boolean) {
                var _this = this;
                if (_this.earth.cesiumWidget.cesiumNavigation) {
                    $(_this.earth.cesiumWidget.cesiumNavigation.distanceLegendDiv).toggle(boolean);
                }
                _this._isShowDistanceLegend = boolean;

                _this.trigger("change");
            }
        },
        isHighResolution    : {
            get: function () {
                return this._isHighResolution;
            },
            set: function (boolean) {
                var _this = this;
                _this.earth.resolutionScale = boolean ? 1.5 : 1;
                _this._isHighResolution = boolean;

                _this.trigger("change");
            }
        },
        isOpenFxaa          : {
            get: function () {
                return this._isOpenFxaa;
            },
            set: function (boolean) {
                var _this = this;

                if (_this.earth.scene.postProcessStages.fxaa) {
                    _this.earth.scene.postProcessStages.fxaa.enabled = boolean;
                } else {
                    _this.earth.scene.fxaa = boolean;
                }
                _this._isOpenFxaa = boolean;

                _this.trigger("change");
            }
        },
        isShowShadow        : {
            get: function () {
                return this._isShowShadow;
            },
            set: function (boolean) {
                var _this = this;
                _this.earth.shadows = boolean;
                _this._isShowShadow = boolean;
                _this.trigger("change");
            }
        },
        isFixedTime         : {
            get: function () {
                return this._isFixedTime;
            },
            set: function (boolean) {
                var _this = this;

                if (boolean) {
                    _this.earth.clock.currentTime = uEarth.JulianDate.fromDate(new Date("2020/01/01 10:00:00"));
                    _this.earth.clock.clockRange = uEarth.ClockRange.CLAMPED;
                    _this.earth.clock.shouldAnimate = false;

                } else {
                    _this.earth.clock.currentTime = uEarth.JulianDate.now();
                    _this.earth.clock.clockRange = uEarth.ClockRange.UNBOUNDED;
                    _this.earth.clock.shouldAnimate = true;
                }


                _this._isFixedTime = boolean;

                _this.trigger("change");
            }
        }
    });

    mhjs.OptionToPropertiesInterface(_class);
    mhjs.EventInterface(_class);

    return _class;

});